package io.sunny.platform.backend.common.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author SUNNY
 * @Date 2025/8/31 12:52
 * @PackageName: io.sunny.platform.backend.common.exception
 * @Description: 统一异常处理
 * @Version 1.0
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);

//    @ExceptionHandler(EntityNotFoundException.class)
//    public ResponseEntity<StandardResponse> handleNotFound(EntityNotFoundException ex) {
//        logger.error("Entity not found: {}", ex.getMessage());
//        return ResponseEntity.status(HttpStatus.NOT_FOUND)
//                .body(StandardResponse.error("NOT_FOUND", ex.getMessage()));
//    }
//    @ExceptionHandler(Exception.class)
//    public ResponseEntity<StandardResponse> handleGeneric(Exception ex) {
//        logger.error("Unexpected error: ", ex);
//        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
//                .body(StandardResponse.error("INTERNAL_ERROR", "服务器内部错误"));
//    }
}
